import { provide, ref } from 'vue';
export default function(options){
	const setup = options.setup;
	const onPullDownRefresh = options.onPullDownRefresh;
	const onReachBottom = options.onReachBottom;
	const onLoad = options.onLoad;
	delete options.setup;
	delete options.onPullDownRefresh;
	delete options.onReachBottom;
	delete options.onLoad;
	const handlePullDown = ref();
	const handleReachBottom = ref();
	const handleLoad = ref();
	return {
		...options,
		onLoad(options){
			if(handleLoad.value){
				handleLoad.value(options);
			}
			onLoad && onLoad.call(this, options);
		},
		onPullDownRefresh() {
			if(handlePullDown.value){
				handlePullDown.value();
			}
			onPullDownRefresh && onPullDownRefresh.call(this);
		},
		onReachBottom(){
			if(handleReachBottom.value){
				handleReachBottom.value();
			}
			onReachBottom && onReachBottom.call(this);
		},
		setup(props, ctx) {
			provide("handlePullDown", handlePullDown);
			provide("handleReachBottom", handleReachBottom);
			provide("handleLoad", handleLoad);
			const re = setup ? setup(props, ctx) : {};
			return {
				...re,
			};
		},
	};
}